/****************************************************************
 * Fulguro
 * Copyright (C) 2004 Christophe Clienti
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 ***************************************************************/

typedef struct {
  %immutable;
  int dim;
  int size_struct;
  int bps;                  
  int spp;                  
  int ref2d;                
  FLGR_Type type;           
  FLGR_Shape shape;         
  int length;               
  void *array;              
  void *array_phantom;      
  %mutable;
}FLGR_Data1D;


%extend FLGR_Data1D {
  FLGR_Data1D(int length, int spp,FLGR_Type type, FLGR_Shape shape) {
    return flgr1d_create(length, spp, type, shape);
  }

  FLGR_Data1D(int length, int spp, FLGR_Type type) {
    return flgr1d_create_signal(length, spp, type);
  }

  FLGR_Data1D(FLGR_Data1D *dat) {
    if(dat->shape == FLGR_NO_SHAPE) {
      return flgr1d_create_from(dat);
    }else {
      return flgr1d_create_neighborhood_from(dat);
    }
  }

  ~FLGR_Data1D() {
    if($self->ref2d<0) flgr1d_destroy($self);
  }

  int __lt__(FLGR_Data1D *dat) {
    return (flgr1d_compare($self, "<", dat)==FLGR_TRUE);
  }
  int __le__(FLGR_Data1D *dat) {
    return (flgr1d_compare($self, "<=", dat)==FLGR_TRUE);
  }
  int __eq__(FLGR_Data1D *dat) {
    return (flgr1d_compare($self, "==", dat)==FLGR_TRUE);
  }
  int __ne__(FLGR_Data1D *dat) {
    return (flgr1d_compare($self, "!=", dat)==FLGR_TRUE);
  }
  int __gt__(FLGR_Data1D *dat) {
    return (flgr1d_compare($self, ">", dat)==FLGR_TRUE);
  }
  int __ge__(FLGR_Data1D *dat) {
    return (flgr1d_compare($self, ">=", dat)==FLGR_TRUE);
  }

  int __lt__(FLGR_Vector *vec) {
    return (flgr1d_compare_const_ptr($self, "<", vec)==FLGR_TRUE);
  }
  int __le__(FLGR_Vector *vec) {
    return (flgr1d_compare_const_ptr($self, "<=", vec)==FLGR_TRUE);
  }
  int __eq__(FLGR_Vector *vec) {
    return (flgr1d_compare_const_ptr($self, "==", vec)==FLGR_TRUE);
  }
  int __ne__(FLGR_Vector *vec) {
    return (flgr1d_compare_const_ptr($self, "!=", vec)==FLGR_TRUE);
  }
  int __gt__(FLGR_Vector *vec) {
    return (flgr1d_compare_const_ptr($self, ">", vec)==FLGR_TRUE);
  }
  int __ge__(FLGR_Vector *vec) {
    return (flgr1d_compare_const_ptr($self, ">=", vec)==FLGR_TRUE);
  }

  int __lt__(SwigObject val) {
    FLGR_Vector *vec = flgr_vector_create($self->spp, $self->type);
    int test = 0;

    if(SwigCheckIntType(val)) {
      switch($self->type) {
      case FLGR_UINT8:
	flgr_vector_populate_from_scalar_fgUINT8(vec,(fgUINT8) (CUInt_FromSwigInt(val)));break;
      case FLGR_UINT16:
	flgr_vector_populate_from_scalar_fgUINT16(vec,(fgUINT16) (CUInt_FromSwigInt(val)));break;
      case FLGR_UINT32:
	flgr_vector_populate_from_scalar_fgUINT32(vec,(fgUINT32) (CUInt_FromSwigInt(val)));break;
      case FLGR_INT8:
	flgr_vector_populate_from_scalar_fgINT8(vec,(fgINT8) (CInt_FromSwigInt(val)));break;
      case FLGR_INT16:
	flgr_vector_populate_from_scalar_fgINT16(vec,(fgINT16) (CInt_FromSwigInt(val)));break;
      case FLGR_INT32:
	flgr_vector_populate_from_scalar_fgINT32(vec,(fgINT32) (CInt_FromSwigInt(val)));break;
      default:
	flgr_vector_destroy(vec);
	return 0;
      }
      
    }else if(SwigCheckDblType(val)) {
      switch($self->type) {
      case FLGR_FLOAT32:
	flgr_vector_populate_from_scalar_fgFLOAT32(vec,(fgFLOAT32) (CDouble_FromSwigFloat(val)));break;
      case FLGR_FLOAT64:
	flgr_vector_populate_from_scalar_fgFLOAT64(vec,(fgFLOAT64) (CDouble_FromSwigFloat(val)));break;
      default:
	flgr_vector_destroy(vec);
	return 0;
      }
       
    }else if(SwigCheckArrayType(val)) {
      if(SwigArraySize(val) >= $self->spp) {
	int size = $self->spp;
	int i;

	if(vec->type==FLGR_UINT8) {
	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgUINT8(vec,i,(fgUINT8) (CUInt_FromSwigInt(SwigGetArrayVal(val,i))));

	}else if(vec->type==FLGR_UINT16) {	
	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgUINT16(vec,i,(fgUINT16) (CUInt_FromSwigInt(SwigGetArrayVal(val,i))));
    
	}else if(vec->type==FLGR_UINT32) {	
  	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgUINT32(vec,i,(fgUINT32) (CUInt_FromSwigInt(SwigGetArrayVal(val,i))));
  
	}else if(vec->type==FLGR_INT8) {	
 	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgINT8(vec,i,(fgINT8) (CInt_FromSwigInt(SwigGetArrayVal(val,i))));

	}else if(vec->type==FLGR_INT16) {	
	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgINT16(vec,i,(fgINT16) (CInt_FromSwigInt(SwigGetArrayVal(val,i))));
    
	}else if(vec->type==FLGR_INT32) {	
 	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgINT32(vec,i,(fgINT32) (CInt_FromSwigInt(SwigGetArrayVal(val,i))));
  
	}else if(vec->type==FLGR_FLOAT32) {		
 	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgFLOAT32(vec,i,(fgFLOAT32) (CDouble_FromSwigFloat(SwigGetArrayVal(val,i))));
   
	}else if(vec->type==FLGR_FLOAT64) {	
	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgFLOAT64(vec,i,(fgFLOAT64) (CDouble_FromSwigFloat(SwigGetArrayVal(val,i))));

	}else if(vec->type==FLGR_BIT) {	
 	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgBIT(vec,i,(fgBIT) (CUInt_FromSwigInt(SwigGetArrayVal(val,i))));
   
	}else {					
	  flgr_vector_destroy(vec);
	  POST_ERROR("unknown type\n");
	  return 0;
	}	
      }else {
	flgr_vector_destroy(vec);
	POST_ERROR("list or array specified too short\n");
	return 0;
      }
    }

    test = (flgr1d_compare_const_ptr($self,"<",vec)==FLGR_TRUE);

    flgr_vector_destroy(vec);
    return test;
  }




  int __le__(SwigObject val) {
    FLGR_Vector *vec = flgr_vector_create($self->spp, $self->type);
    int test = 0;

    if(SwigCheckIntType(val)) {
      switch($self->type) {
      case FLGR_UINT8:
	flgr_vector_populate_from_scalar_fgUINT8(vec,(fgUINT8) (CUInt_FromSwigInt(val)));break;
      case FLGR_UINT16:
	flgr_vector_populate_from_scalar_fgUINT16(vec,(fgUINT16) (CUInt_FromSwigInt(val)));break;
      case FLGR_UINT32:
	flgr_vector_populate_from_scalar_fgUINT32(vec,(fgUINT32) (CUInt_FromSwigInt(val)));break;
      case FLGR_INT8:
	flgr_vector_populate_from_scalar_fgINT8(vec,(fgINT8) (CInt_FromSwigInt(val)));break;
      case FLGR_INT16:
	flgr_vector_populate_from_scalar_fgINT16(vec,(fgINT16) (CInt_FromSwigInt(val)));break;
      case FLGR_INT32:
	flgr_vector_populate_from_scalar_fgINT32(vec,(fgINT32) (CInt_FromSwigInt(val)));break;
      default:
	flgr_vector_destroy(vec);
	return 0;
      }
      
    }else if(SwigCheckDblType(val)) {
      switch($self->type) {
      case FLGR_FLOAT32:
	flgr_vector_populate_from_scalar_fgFLOAT32(vec,(fgFLOAT32) (CDouble_FromSwigFloat(val)));break;
      case FLGR_FLOAT64:
	flgr_vector_populate_from_scalar_fgFLOAT64(vec,(fgFLOAT64) (CDouble_FromSwigFloat(val)));break;
      default:
	flgr_vector_destroy(vec);
	return 0;
      }
       
    }else if(SwigCheckArrayType(val)) {
      if(SwigArraySize(val) >= $self->spp) {
	int size = $self->spp;
	int i;

	if(vec->type==FLGR_UINT8) {
	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgUINT8(vec,i,(fgUINT8) (CUInt_FromSwigInt(SwigGetArrayVal(val,i))));

	}else if(vec->type==FLGR_UINT16) {	
	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgUINT16(vec,i,(fgUINT16) (CUInt_FromSwigInt(SwigGetArrayVal(val,i))));
    
	}else if(vec->type==FLGR_UINT32) {	
  	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgUINT32(vec,i,(fgUINT32) (CUInt_FromSwigInt(SwigGetArrayVal(val,i))));
  
	}else if(vec->type==FLGR_INT8) {	
 	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgINT8(vec,i,(fgINT8) (CInt_FromSwigInt(SwigGetArrayVal(val,i))));

	}else if(vec->type==FLGR_INT16) {	
	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgINT16(vec,i,(fgINT16) (CInt_FromSwigInt(SwigGetArrayVal(val,i))));
    
	}else if(vec->type==FLGR_INT32) {	
 	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgINT32(vec,i,(fgINT32) (CInt_FromSwigInt(SwigGetArrayVal(val,i))));
  
	}else if(vec->type==FLGR_FLOAT32) {		
 	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgFLOAT32(vec,i,(fgFLOAT32) (CDouble_FromSwigFloat(SwigGetArrayVal(val,i))));
   
	}else if(vec->type==FLGR_FLOAT64) {	
	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgFLOAT64(vec,i,(fgFLOAT64) (CDouble_FromSwigFloat(SwigGetArrayVal(val,i))));

	}else if(vec->type==FLGR_BIT) {	
 	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgBIT(vec,i,(fgBIT) (CUInt_FromSwigInt(SwigGetArrayVal(val,i))));
   
	}else {					
	  flgr_vector_destroy(vec);
	  POST_ERROR("unknown type\n");
	  return 0;
	}	
      }else {
	flgr_vector_destroy(vec);
	POST_ERROR("list or array specified too short\n");
	return 0;
      }
    }

    test = (flgr1d_compare_const_ptr($self,"<=",vec)==FLGR_TRUE);

    flgr_vector_destroy(vec);
    return test;
  }



  int __eq__(SwigObject val) {
    FLGR_Vector *vec = flgr_vector_create($self->spp, $self->type);
    int test = 0;

    if(SwigCheckIntType(val)) {
      switch($self->type) {
      case FLGR_UINT8:
	flgr_vector_populate_from_scalar_fgUINT8(vec,(fgUINT8) (CUInt_FromSwigInt(val)));break;
      case FLGR_UINT16:
	flgr_vector_populate_from_scalar_fgUINT16(vec,(fgUINT16) (CUInt_FromSwigInt(val)));break;
      case FLGR_UINT32:
	flgr_vector_populate_from_scalar_fgUINT32(vec,(fgUINT32) (CUInt_FromSwigInt(val)));break;
      case FLGR_INT8:
	flgr_vector_populate_from_scalar_fgINT8(vec,(fgINT8) (CInt_FromSwigInt(val)));break;
      case FLGR_INT16:
	flgr_vector_populate_from_scalar_fgINT16(vec,(fgINT16) (CInt_FromSwigInt(val)));break;
      case FLGR_INT32:
	flgr_vector_populate_from_scalar_fgINT32(vec,(fgINT32) (CInt_FromSwigInt(val)));break;
      default:
	flgr_vector_destroy(vec);
	return 0;
      }
      
    }else if(SwigCheckDblType(val)) {
      switch($self->type) {
      case FLGR_FLOAT32:
	flgr_vector_populate_from_scalar_fgFLOAT32(vec,(fgFLOAT32) (CDouble_FromSwigFloat(val)));break;
      case FLGR_FLOAT64:
	flgr_vector_populate_from_scalar_fgFLOAT64(vec,(fgFLOAT64) (CDouble_FromSwigFloat(val)));break;
      default:
	flgr_vector_destroy(vec);
	return 0;
      }
       
    }else if(SwigCheckArrayType(val)) {
      if(SwigArraySize(val) >= $self->spp) {
	int size = $self->spp;
	int i;

	if(vec->type==FLGR_UINT8) {
	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgUINT8(vec,i,(fgUINT8) (CUInt_FromSwigInt(SwigGetArrayVal(val,i))));

	}else if(vec->type==FLGR_UINT16) {	
	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgUINT16(vec,i,(fgUINT16) (CUInt_FromSwigInt(SwigGetArrayVal(val,i))));
    
	}else if(vec->type==FLGR_UINT32) {	
  	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgUINT32(vec,i,(fgUINT32) (CUInt_FromSwigInt(SwigGetArrayVal(val,i))));
  
	}else if(vec->type==FLGR_INT8) {	
 	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgINT8(vec,i,(fgINT8) (CInt_FromSwigInt(SwigGetArrayVal(val,i))));

	}else if(vec->type==FLGR_INT16) {	
	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgINT16(vec,i,(fgINT16) (CInt_FromSwigInt(SwigGetArrayVal(val,i))));
    
	}else if(vec->type==FLGR_INT32) {	
 	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgINT32(vec,i,(fgINT32) (CInt_FromSwigInt(SwigGetArrayVal(val,i))));
  
	}else if(vec->type==FLGR_FLOAT32) {		
 	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgFLOAT32(vec,i,(fgFLOAT32) (CDouble_FromSwigFloat(SwigGetArrayVal(val,i))));
   
	}else if(vec->type==FLGR_FLOAT64) {	
	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgFLOAT64(vec,i,(fgFLOAT64) (CDouble_FromSwigFloat(SwigGetArrayVal(val,i))));

	}else if(vec->type==FLGR_BIT) {	
 	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgBIT(vec,i,(fgBIT) (CUInt_FromSwigInt(SwigGetArrayVal(val,i))));
   
	}else {					
	  flgr_vector_destroy(vec);
	  POST_ERROR("unknown type\n");
	  return 0;
	}	
      }else {
	flgr_vector_destroy(vec);
	POST_ERROR("list or array specified too short\n");
	return 0;
      }
    }

    test = (flgr1d_compare_const_ptr($self,"==",vec)==FLGR_TRUE);

    flgr_vector_destroy(vec);
    return test;
  }



  int __ne__(SwigObject val) {
    FLGR_Vector *vec = flgr_vector_create($self->spp, $self->type);
    int test = 0;

    if(SwigCheckIntType(val)) {
      switch($self->type) {
      case FLGR_UINT8:
	flgr_vector_populate_from_scalar_fgUINT8(vec,(fgUINT8) (CUInt_FromSwigInt(val)));break;
      case FLGR_UINT16:
	flgr_vector_populate_from_scalar_fgUINT16(vec,(fgUINT16) (CUInt_FromSwigInt(val)));break;
      case FLGR_UINT32:
	flgr_vector_populate_from_scalar_fgUINT32(vec,(fgUINT32) (CUInt_FromSwigInt(val)));break;
      case FLGR_INT8:
	flgr_vector_populate_from_scalar_fgINT8(vec,(fgINT8) (CInt_FromSwigInt(val)));break;
      case FLGR_INT16:
	flgr_vector_populate_from_scalar_fgINT16(vec,(fgINT16) (CInt_FromSwigInt(val)));break;
      case FLGR_INT32:
	flgr_vector_populate_from_scalar_fgINT32(vec,(fgINT32) (CInt_FromSwigInt(val)));break;
      default:
	flgr_vector_destroy(vec);
	return 0;
      }
      
    }else if(SwigCheckDblType(val)) {
      switch($self->type) {
      case FLGR_FLOAT32:
	flgr_vector_populate_from_scalar_fgFLOAT32(vec,(fgFLOAT32) (CDouble_FromSwigFloat(val)));break;
      case FLGR_FLOAT64:
	flgr_vector_populate_from_scalar_fgFLOAT64(vec,(fgFLOAT64) (CDouble_FromSwigFloat(val)));break;
      default:
	flgr_vector_destroy(vec);
	return 0;
      }
       
    }else if(SwigCheckArrayType(val)) {
      if(SwigArraySize(val) >= $self->spp) {
	int size = $self->spp;
	int i;

	if(vec->type==FLGR_UINT8) {
	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgUINT8(vec,i,(fgUINT8) (CUInt_FromSwigInt(SwigGetArrayVal(val,i))));

	}else if(vec->type==FLGR_UINT16) {	
	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgUINT16(vec,i,(fgUINT16) (CUInt_FromSwigInt(SwigGetArrayVal(val,i))));
    
	}else if(vec->type==FLGR_UINT32) {	
  	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgUINT32(vec,i,(fgUINT32) (CUInt_FromSwigInt(SwigGetArrayVal(val,i))));
  
	}else if(vec->type==FLGR_INT8) {	
 	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgINT8(vec,i,(fgINT8) (CInt_FromSwigInt(SwigGetArrayVal(val,i))));

	}else if(vec->type==FLGR_INT16) {	
	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgINT16(vec,i,(fgINT16) (CInt_FromSwigInt(SwigGetArrayVal(val,i))));
    
	}else if(vec->type==FLGR_INT32) {	
 	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgINT32(vec,i,(fgINT32) (CInt_FromSwigInt(SwigGetArrayVal(val,i))));
  
	}else if(vec->type==FLGR_FLOAT32) {		
 	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgFLOAT32(vec,i,(fgFLOAT32) (CDouble_FromSwigFloat(SwigGetArrayVal(val,i))));
   
	}else if(vec->type==FLGR_FLOAT64) {	
	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgFLOAT64(vec,i,(fgFLOAT64) (CDouble_FromSwigFloat(SwigGetArrayVal(val,i))));

	}else if(vec->type==FLGR_BIT) {	
 	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgBIT(vec,i,(fgBIT) (CUInt_FromSwigInt(SwigGetArrayVal(val,i))));
   
	}else {					
	  flgr_vector_destroy(vec);
	  POST_ERROR("unknown type\n");
	  return 0;
	}	
      }else {
	flgr_vector_destroy(vec);
	POST_ERROR("list or array specified too short\n");
	return 0;
      }
    }

    test = (flgr1d_compare_const_ptr($self,"!=",vec)==FLGR_TRUE);

    flgr_vector_destroy(vec);
    return test;
  }




  int __gt__(SwigObject val) {
    FLGR_Vector *vec = flgr_vector_create($self->spp, $self->type);
    int test = 0;

    if(SwigCheckIntType(val)) {
      switch($self->type) {
      case FLGR_UINT8:
	flgr_vector_populate_from_scalar_fgUINT8(vec,(fgUINT8) (CUInt_FromSwigInt(val)));break;
      case FLGR_UINT16:
	flgr_vector_populate_from_scalar_fgUINT16(vec,(fgUINT16) (CUInt_FromSwigInt(val)));break;
      case FLGR_UINT32:
	flgr_vector_populate_from_scalar_fgUINT32(vec,(fgUINT32) (CUInt_FromSwigInt(val)));break;
      case FLGR_INT8:
	flgr_vector_populate_from_scalar_fgINT8(vec,(fgINT8) (CInt_FromSwigInt(val)));break;
      case FLGR_INT16:
	flgr_vector_populate_from_scalar_fgINT16(vec,(fgINT16) (CInt_FromSwigInt(val)));break;
      case FLGR_INT32:
	flgr_vector_populate_from_scalar_fgINT32(vec,(fgINT32) (CInt_FromSwigInt(val)));break;
      default:
	flgr_vector_destroy(vec);
	return 0;
      }
      
    }else if(SwigCheckDblType(val)) {
      switch($self->type) {
      case FLGR_FLOAT32:
	flgr_vector_populate_from_scalar_fgFLOAT32(vec,(fgFLOAT32) (CDouble_FromSwigFloat(val)));break;
      case FLGR_FLOAT64:
	flgr_vector_populate_from_scalar_fgFLOAT64(vec,(fgFLOAT64) (CDouble_FromSwigFloat(val)));break;
      default:
	flgr_vector_destroy(vec);
	return 0;
      }
       
    }else if(SwigCheckArrayType(val)) {
      if(SwigArraySize(val) >= $self->spp) {
	int size = $self->spp;
	int i;

	if(vec->type==FLGR_UINT8) {
	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgUINT8(vec,i,(fgUINT8) (CUInt_FromSwigInt(SwigGetArrayVal(val,i))));

	}else if(vec->type==FLGR_UINT16) {	
	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgUINT16(vec,i,(fgUINT16) (CUInt_FromSwigInt(SwigGetArrayVal(val,i))));
    
	}else if(vec->type==FLGR_UINT32) {	
  	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgUINT32(vec,i,(fgUINT32) (CUInt_FromSwigInt(SwigGetArrayVal(val,i))));
  
	}else if(vec->type==FLGR_INT8) {	
 	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgINT8(vec,i,(fgINT8) (CInt_FromSwigInt(SwigGetArrayVal(val,i))));

	}else if(vec->type==FLGR_INT16) {	
	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgINT16(vec,i,(fgINT16) (CInt_FromSwigInt(SwigGetArrayVal(val,i))));
    
	}else if(vec->type==FLGR_INT32) {	
 	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgINT32(vec,i,(fgINT32) (CInt_FromSwigInt(SwigGetArrayVal(val,i))));
  
	}else if(vec->type==FLGR_FLOAT32) {		
 	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgFLOAT32(vec,i,(fgFLOAT32) (CDouble_FromSwigFloat(SwigGetArrayVal(val,i))));
   
	}else if(vec->type==FLGR_FLOAT64) {	
	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgFLOAT64(vec,i,(fgFLOAT64) (CDouble_FromSwigFloat(SwigGetArrayVal(val,i))));

	}else if(vec->type==FLGR_BIT) {	
 	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgBIT(vec,i,(fgBIT) (CUInt_FromSwigInt(SwigGetArrayVal(val,i))));
   
	}else {					
	  flgr_vector_destroy(vec);
	  POST_ERROR("unknown type\n");
	  return 0;
	}	
      }else {
	flgr_vector_destroy(vec);
	POST_ERROR("list or array specified too short\n");
	return 0;
      }
    }

    test = (flgr1d_compare_const_ptr($self,">",vec)==FLGR_TRUE);

    flgr_vector_destroy(vec);
    return test;
  }


  int __ge__(SwigObject val) {
    FLGR_Vector *vec = flgr_vector_create($self->spp, $self->type);
    int test = 0;

    if(SwigCheckIntType(val)) {
      switch($self->type) {
      case FLGR_UINT8:
	flgr_vector_populate_from_scalar_fgUINT8(vec,(fgUINT8) (CUInt_FromSwigInt(val)));break;
      case FLGR_UINT16:
	flgr_vector_populate_from_scalar_fgUINT16(vec,(fgUINT16) (CUInt_FromSwigInt(val)));break;
      case FLGR_UINT32:
	flgr_vector_populate_from_scalar_fgUINT32(vec,(fgUINT32) (CUInt_FromSwigInt(val)));break;
      case FLGR_INT8:
	flgr_vector_populate_from_scalar_fgINT8(vec,(fgINT8) (CInt_FromSwigInt(val)));break;
      case FLGR_INT16:
	flgr_vector_populate_from_scalar_fgINT16(vec,(fgINT16) (CInt_FromSwigInt(val)));break;
      case FLGR_INT32:
	flgr_vector_populate_from_scalar_fgINT32(vec,(fgINT32) (CInt_FromSwigInt(val)));break;
      default:
	flgr_vector_destroy(vec);
	return 0;
      }
      
    }else if(SwigCheckDblType(val)) {
      switch($self->type) {
      case FLGR_FLOAT32:
	flgr_vector_populate_from_scalar_fgFLOAT32(vec,(fgFLOAT32) (CDouble_FromSwigFloat(val)));break;
      case FLGR_FLOAT64:
	flgr_vector_populate_from_scalar_fgFLOAT64(vec,(fgFLOAT64) (CDouble_FromSwigFloat(val)));break;
      default:
	flgr_vector_destroy(vec);
	return 0;
      }
       
    }else if(SwigCheckArrayType(val)) {
      if(SwigArraySize(val) >= $self->spp) {
	int size = $self->spp;
	int i;

	if(vec->type==FLGR_UINT8) {
	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgUINT8(vec,i,(fgUINT8) (CUInt_FromSwigInt(SwigGetArrayVal(val,i))));

	}else if(vec->type==FLGR_UINT16) {	
	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgUINT16(vec,i,(fgUINT16) (CUInt_FromSwigInt(SwigGetArrayVal(val,i))));
    
	}else if(vec->type==FLGR_UINT32) {	
  	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgUINT32(vec,i,(fgUINT32) (CUInt_FromSwigInt(SwigGetArrayVal(val,i))));
  
	}else if(vec->type==FLGR_INT8) {	
 	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgINT8(vec,i,(fgINT8) (CInt_FromSwigInt(SwigGetArrayVal(val,i))));

	}else if(vec->type==FLGR_INT16) {	
	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgINT16(vec,i,(fgINT16) (CInt_FromSwigInt(SwigGetArrayVal(val,i))));
    
	}else if(vec->type==FLGR_INT32) {	
 	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgINT32(vec,i,(fgINT32) (CInt_FromSwigInt(SwigGetArrayVal(val,i))));
  
	}else if(vec->type==FLGR_FLOAT32) {		
 	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgFLOAT32(vec,i,(fgFLOAT32) (CDouble_FromSwigFloat(SwigGetArrayVal(val,i))));
   
	}else if(vec->type==FLGR_FLOAT64) {	
	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgFLOAT64(vec,i,(fgFLOAT64) (CDouble_FromSwigFloat(SwigGetArrayVal(val,i))));

	}else if(vec->type==FLGR_BIT) {	
 	  for(i=0 ; i<size ; i++) 
	    flgr_vector_set_element_fgBIT(vec,i,(fgBIT) (CUInt_FromSwigInt(SwigGetArrayVal(val,i))));
   
	}else {					
	  flgr_vector_destroy(vec);
	  POST_ERROR("unknown type\n");
	  return 0;
	}	
      }else {
	flgr_vector_destroy(vec);
	POST_ERROR("list or array specified too short\n");
	return 0;
      }
    }

    test = (flgr1d_compare_const_ptr($self,">=",vec)==FLGR_TRUE);

    flgr_vector_destroy(vec);
    return test;
  }





  FLGR_Vector *__getitem__(int j) {
    FLGR_Vector *vec=NULL;
    vec= flgr_vector_create($self->spp, $self->type);
    flgr1d_get_data_vector($self,j,vec);
    return vec;
  }

  void __setitem__(int j, FLGR_Vector *vec) {
    flgr1d_set_data_vector($self,j,vec);
  }

  void __setitem__(int j,SwigObject obj) {
    FLGR_Vector *vec = flgr_vector_create($self->spp,$self->type);
    int size=$self->spp;
    void *tab;
    int i;
 
    if(vec==NULL) {
      POST_ERROR("Vector init failed!\n");
      return;
    }

    tab = vec->array; 
    
    if(PyList_Check(obj)) {               // Vector object
      if($self->type==FLGR_UINT8) {
	for(i=0 ; i<size ; i++)
	  flgr_set_array_fgUINT8(tab,i,(fgUINT8) (CUInt_FromSwigInt(SwigGetArrayVal(obj,i))));

      }else if($self->type==FLGR_UINT16) {	
	for(i=0 ; i<size ; i++)
	  flgr_set_array_fgUINT16(tab,i,(fgUINT16) (CUInt_FromSwigInt(SwigGetArrayVal(obj,i))));
    
      }else if($self->type==FLGR_UINT32) {	
	for(i=0 ; i<size ; i++)
	  flgr_set_array_fgUINT32(tab,i,(fgUINT32) (CUInt_FromSwigInt(SwigGetArrayVal(obj,i))));
   
      }else if($self->type==FLGR_INT8) {	
	for(i=0 ; i<size ; i++)
	  flgr_set_array_fgINT8(tab,i,(fgINT8) (CInt_FromSwigInt(SwigGetArrayVal(obj,i))));
    
      }else if($self->type==FLGR_INT16) {	
	for(i=0 ; i<size ; i++)
	  flgr_set_array_fgINT16(tab,i,(fgINT16) (CInt_FromSwigInt(SwigGetArrayVal(obj,i))));
   
      }else if($self->type==FLGR_INT32) {	
	for(i=0 ; i<size ; i++)
	  flgr_set_array_fgINT32(tab,i,(fgINT32) (CInt_FromSwigInt(SwigGetArrayVal(obj,i))));
  
      }else if($self->type==FLGR_FLOAT32) {		
	for(i=0 ; i<size ; i++)
	  flgr_set_array_fgFLOAT32(tab,i,(fgFLOAT32) (CDouble_FromSwigFloat(SwigGetArrayVal(obj,i))));
   
      }else if($self->type==FLGR_FLOAT64) {	
	for(i=0 ; i<size ; i++)
	  flgr_set_array_fgFLOAT64(tab,i,(fgFLOAT64) (CDouble_FromSwigFloat(SwigGetArrayVal(obj,i))));

      }else if($self->type==FLGR_BIT) {	
	for(i=0 ; i<size ; i++)
	  flgr_set_array_fgBIT(tab,i,(fgBIT) (CUInt_FromSwigInt(SwigGetArrayVal(obj,i))));
  
      }else {					
	POST_ERROR("unknown type\n");
	flgr_vector_destroy(vec);
	return;
      }
      
    }else if(SwigCheckDblType(obj) || SwigCheckIntType(obj)) {   // SCALAR object
     
      if($self->type==FLGR_UINT8) {
	flgr_vector_populate_from_scalar_fgUINT8(vec,(fgUINT8) (CUInt_FromSwigInt(obj)));
	  
      }else if($self->type==FLGR_UINT16) {	
	flgr_vector_populate_from_scalar_fgUINT16(vec,(fgUINT16) (CUInt_FromSwigInt(obj)));
	  
      }else if($self->type==FLGR_UINT32) {	
	flgr_vector_populate_from_scalar_fgUINT32(vec,(fgUINT32) (CUInt_FromSwigInt(obj)));
	  
      }else if($self->type==FLGR_INT8) {	
	flgr_vector_populate_from_scalar_fgINT8(vec,(fgINT8) (CInt_FromSwigInt(obj)));
	  
      }else if($self->type==FLGR_INT16) {	
	flgr_vector_populate_from_scalar_fgINT16(vec,(fgINT16) (CInt_FromSwigInt(obj)));
	  
      }else if($self->type==FLGR_INT32) {	
	flgr_vector_populate_from_scalar_fgINT32(vec,(fgINT32) (CInt_FromSwigInt(obj)));
	  
      }else if($self->type==FLGR_FLOAT32) {		
	flgr_vector_populate_from_scalar_fgFLOAT32(vec,(fgFLOAT32) (CDouble_FromSwigFloat(obj)));
	  
      }else if($self->type==FLGR_FLOAT64) {	
	flgr_vector_populate_from_scalar_fgFLOAT64(vec,(fgFLOAT64) (CDouble_FromSwigFloat(obj)));
	  
      }else if($self->type==FLGR_BIT) {	
	flgr_vector_populate_from_scalar_fgBIT(vec,(fgBIT) (CUInt_FromSwigInt(obj)));
	  
      }else {					
	POST_ERROR("unknown type\n");
	flgr_vector_destroy(vec);
	return;
      }

    }else {
      POST_ERROR("unknown object\n");
      flgr_vector_destroy(vec);
      return;
    }

    flgr1d_set_data_vector($self,j,vec);

    flgr_vector_destroy(vec);
  }

  void from_string(SwigObject obj) {
    char *str = CString_FromSwigString(obj);
    flgr1d_import_raw_ptr($self, (void *) str);
  }

  SwigObject to_string() {
    SwigObject obj;
    void *str = malloc($self->spp  * $self->length * flgr_get_sizeof($self->type));
    flgr1d_export_raw_ptr(str,$self);
    obj = SwigString_FromCString(str);
    free(str);
    return obj;
  }



  SwigObject to_raw() {
    void *tab = $self->array;
    int size = $self->length*$self->spp;
    int i;
    SwigObject obj = SwigObjectEmpty;    

    obj = SwigCreateArray(size);

    if($self->type==FLGR_UINT8) {
      for(i=0 ; i<size ; i++) 
	SwigSetArrayVal( obj, i, SwigInt_FromCUInt((unsigned int) flgr1d_get_data_array_fgUINT8(tab,i)) );
      
    }else if($self->type==FLGR_UINT16) {
      for(i=0 ; i<size ; i++) 
	SwigSetArrayVal( obj, i, SwigInt_FromCUInt((unsigned int) flgr1d_get_data_array_fgUINT16(tab,i)) );
      
    }else if($self->type==FLGR_UINT32) {
      for(i=0 ; i<size ; i++) 
	SwigSetArrayVal( obj, i, SwigInt_FromCUInt((unsigned int) flgr1d_get_data_array_fgUINT32(tab,i)) );
     
    }else if($self->type==FLGR_INT8) {
      for(i=0 ; i<size ; i++) 
	SwigSetArrayVal( obj, i, SwigInt_FromCUInt((int) flgr1d_get_data_array_fgINT8(tab,i)) );
     
    }else if($self->type==FLGR_INT16) {
      for(i=0 ; i<size ; i++) 
	SwigSetArrayVal( obj, i, SwigInt_FromCInt((int) flgr1d_get_data_array_fgINT16(tab,i)) );
    
    }else if($self->type==FLGR_INT32) {
      for(i=0 ; i<size ; i++) 
	SwigSetArrayVal( obj, i, SwigInt_FromCInt((int) flgr1d_get_data_array_fgINT32(tab,i)) );
      
    }else if($self->type==FLGR_FLOAT32) {
      for(i=0 ; i<size ; i++) 
	SwigSetArrayVal( obj, i, SwigFloat_FromCDouble((double) flgr1d_get_data_array_fgFLOAT32(tab,i)) );
        
    }else if($self->type==FLGR_FLOAT64) {
      for(i=0 ; i<size ; i++) 
	SwigSetArrayVal( obj, i, SwigFloat_FromCDouble((double) flgr1d_get_data_array_fgFLOAT64(tab,i)) );
     
    }else if($self->type==FLGR_BIT) {
      for(i=0 ; i<size ; i++) 
	SwigSetArrayVal( obj, i, SwigInt_FromCUInt((unsigned int) flgr1d_get_data_array_fgBIT(tab,i)) );

    }else {
      POST_ERROR("type unknown\n");
      return SwigObjectEmpty;
    }
    
    return obj;
  }

  void from_raw( SwigObject raw_row) {
    void *tab = $self->array;
    int size = $self->length*$self->spp;
    int i;

    if($self->type==FLGR_UINT8) {
      for(i=0 ; i<size ; i++)
	flgr1d_set_data_array_fgUINT8(tab,i,(fgUINT8) (CUInt_FromSwigInt(SwigGetArrayVal(raw_row,i))));

    }else if($self->type==FLGR_UINT16) {	
      for(i=0 ; i<size ; i++)
	flgr1d_set_data_array_fgUINT16(tab,i,(fgUINT16) (CUInt_FromSwigInt(SwigGetArrayVal(raw_row,i))));
    
    }else if($self->type==FLGR_UINT32) {	
       for(i=0 ; i<size ; i++)
	flgr1d_set_data_array_fgUINT32(tab,i,(fgUINT32) (CUInt_FromSwigInt(SwigGetArrayVal(raw_row,i))));
   
    }else if($self->type==FLGR_INT8) {	
       for(i=0 ; i<size ; i++)
	flgr1d_set_data_array_fgINT8(tab,i,(fgINT8) (CInt_FromSwigInt(SwigGetArrayVal(raw_row,i))));
    
    }else if($self->type==FLGR_INT16) {	
       for(i=0 ; i<size ; i++)
	flgr1d_set_data_array_fgINT16(tab,i,(fgINT16) (CInt_FromSwigInt(SwigGetArrayVal(raw_row,i))));
   
    }else if($self->type==FLGR_INT32) {	
       for(i=0 ; i<size ; i++)
	flgr1d_set_data_array_fgINT32(tab,i,(fgINT32) (CInt_FromSwigInt(SwigGetArrayVal(raw_row,i))));
  
    }else if($self->type==FLGR_FLOAT32) {		
       for(i=0 ; i<size ; i++)
	flgr1d_set_data_array_fgFLOAT32(tab,i,(fgFLOAT32) (CDouble_FromSwigFloat(SwigGetArrayVal(raw_row,i))));
   
    }else if($self->type==FLGR_FLOAT64) {	
      for(i=0 ; i<size ; i++)
	flgr1d_set_data_array_fgFLOAT64(tab,i,(fgFLOAT64) (CDouble_FromSwigFloat(SwigGetArrayVal(raw_row,i))));

    }else if($self->type==FLGR_BIT) {	
       for(i=0 ; i<size ; i++)
	flgr1d_set_data_array_fgBIT(tab,i,(fgBIT) (CUInt_FromSwigInt(SwigGetArrayVal(raw_row,i))));
  
    }else {					
      POST_ERROR("unknown type\n");
    }

  }

};





%feature("autodoc","""
[in] Length (Integer)
[in] Sample Per Pixel (Integer)
[in] Type (FLGR_Type)
[in] Shape (FLGR_Shape)
[return] FLGR_Data1D object \n 
Create a 1d data
""") flgr1d_create;
FLGR_Data1D *flgr1d_create(int length, int spp,  FLGR_Type type, FLGR_Shape shape);

%feature("autodoc","""
[in] dat (FLGR_Data1D)
[return] FLGR_Data1D object \n 
Create a 1d data using informations given in the object \"dat\"
""") flgr1d_create_from;
FLGR_Data1D *flgr1d_create_from(FLGR_Data1D *dat);

%feature("autodoc","""
[in] Length (Integer)
[in] Sample Per Pixel (Integer)
[in] Type (FLGR_Type)
[return] FLGR_Data1D object \n 
Create a 1d data signal
""") flgr1d_create_signal;
FLGR_Data1D *flgr1d_create_signal(int length,  int spp, FLGR_Type type);

%feature("autodoc","""
[in] dat (FLGR_Data1D)
[return] FLGR_Data1D object \n 
Create a 1d data signal using informations given in the object \"dat\"
""") flgr1d_create_signal_from;
FLGR_Data1D *flgr1d_create_signal_from(FLGR_Data1D *dat);

%feature("autodoc","""
[in] Length (Integer)
[in] Sample Per Pixel (Integer)
[in] Type (FLGR_Type)
[in] Shape (FLGR_Shape)
[return] FLGR_Data1D object \n 
Create a 1d data neighborhood
""") flgr1d_create_neighborhood;
FLGR_Data1D *flgr1d_create_neighborhood(int length,  int spp, FLGR_Type type, FLGR_Shape shape);

%feature("autodoc","""
[in] dat (FLGR_Data1D)
[return] FLGR_Data1D object \n 
Create a 1d data neighborhood definition using informations given in the object \"dat\"
""") flgr1d_create_neighborhood_from;
FLGR_Data1D *flgr1d_create_neighborhood_from(FLGR_Data1D *dat);

%feature("autodoc","""
[in] dat1 (FLGR_Data1D)
[in] dat2 (FLGR_Data1D)
[return] FLGR_Ret\n 
Check if two data have the same length
""") flgr1d_is_data_same_length;
FLGR_Ret flgr1d_is_data_same_length(FLGR_Data1D *dat1, FLGR_Data1D *dat2);

%feature("autodoc","""
[in] dat1 (FLGR_Data1D)
[in] dat2 (FLGR_Data1D)
[return] FLGR_Ret\n 
Check if two data have the same type
""") flgr1d_is_data_same_type;
FLGR_Ret flgr1d_is_data_same_type(FLGR_Data1D *dat1, FLGR_Data1D *dat2);

%feature("autodoc","""
[in] dat1 (FLGR_Data1D)
[in] dat2 (FLGR_Data1D)
[return] FLGR_Ret\n 
Check if two data have the same spp
""") flgr1d_is_data_same_spp;
FLGR_Ret flgr1d_is_data_same_spp(FLGR_Data1D *dat1, FLGR_Data1D *dat2);

%feature("autodoc","""
[in] dat1 (FLGR_Data1D)
[in] dat2 (FLGR_Data1D)
[in] callingFunction (String)
[return] FLGR_Ret\n 
Check if two data have the same attributes (type, length, spp)
""") flgr1d_is_data_same_type;
FLGR_Ret flgr1d_is_data_same_attributes(FLGR_Data1D *data1, FLGR_Data1D *data2, 
					const char *callingFunction);

%feature("autodoc","""
[in] data (FLGR_Data1D)
[in] type (FLGR_Type)
[return] Integer\n 
Return 1 if data.type is equal to type
""") flgr1d_data_is_type;
int flgr1d_data_is_type(FLGR_Data1D *data, FLGR_Type type);

%feature("autodoc","""
[in] data (FLGR_Data1D)
[in] shape (FLGR_Shape)
[return] Integer\n 
Return 1 if data.shape is equal to shape
""") flgr1d_data_is_shape;
int flgr1d_data_is_shape(FLGR_Data1D *data, FLGR_Shape shape);

%feature("autodoc","""
[inout] dat (FLGR_Data1D)
[in] shape (FLGR_Shape)
[return] nothing\n 
Change the data shape
""") flgr1d_data_set_shape;
void flgr1d_data_set_shape(FLGR_Data1D *dat, FLGR_Shape shape);

%feature("autodoc","""
[inout] dat (FLGR_Data1D)
[return] FLGR_Ret\n 
Clear the data values
""") flgr1d_clear_all;
FLGR_Ret flgr1d_clear_all(FLGR_Data1D *data);
